﻿using Avalonia.Controls;
using Avalonia.Controls.Templates;
using GitNet.WindowsApp.GitView;
using GitNet.WindowsApp.Models;
using LibGit2Sharp;

namespace GitNet.WindowsApp;

public class ViewTemplate : IDataTemplate
{
    public IControl Build(object param)
    {
        if (param is Commit commit)
            return new CommitView { DataContext = commit };

        if (param is Branch branch)
            return new BranchView { DataContext = branch };

        if (param is StatusModel model)
            return new StatusView(model);

        if (param is Remote remote)
            return new RemoteView() { DataContext = remote };

        return new TextBlock();
    }

    public bool Match(object data) => true;
}